package com.zt.ztyh.config;

import com.zt.ztyh.interceptor.LoginAuthInterceptor;
import com.zt.ztyh.properties.UrlProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Java之父卫相阳
 * @date 2024/4/3 11:55
 * OverSion04
 */
@Configuration
public class MyWebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginAuthInterceptor loginAuthInterceptor;
    @Autowired
    private UrlProperties urlProperties;
    @Override
    //注册拦截器
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginAuthInterceptor)
                .excludePathPatterns(urlProperties.getNoAuthUrls())
                .addPathPatterns("/**");//所有资源

    }
}
